package com.wise.service.portal.content.webcolumns;

import com.wise.entities.content.ArticleColumn;
import com.wise.framework.dao.SqlSelect;
import com.wise.framework.daomodel.DaoList;
import com.wise.model.content.enums.ArticleColumnShowStatus;
import com.wise.summer.v1.portal.content.webcolumns.ListWebColumns;
import org.springframework.stereotype.Service;
import org.summerframework.model.SummerService;
import org.summerframework.model.SummerServiceBean;

import java.util.List;

@Service
@SummerService
public class ListWebColumnsService implements SummerServiceBean<ListWebColumns> {
	@Override
	public void sum(ListWebColumns model) {
		SqlSelect sql = SqlSelect.selec("*")
				.fromClassName(ArticleColumn.class)
				.eq(ArticleColumn._showState, ArticleColumnShowStatus.SHOW.value())
				.eqLang(ArticleColumn._lang)
				.eq("type", model.getType())
				.order_by(ArticleColumn._sort)
				.order_by(ArticleColumn._id + " desc");
		List<ListWebColumns.Result> articleColumnList = DaoList.s(ListWebColumns.Result.class, sql);
		model.setSummerResult(articleColumnList);
	}
}
